package com.businessportal.web.ckeditor.filebrowser;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by Vadim on 6/27/14.
 */
public class CommandDetector {

    public enum CkCommand{
        Init,
        GetFolders,
        GetFiles
    }

    public enum CkContentType{
        Image,
        Flash
    }

    public static ICommand getCurrentCommand(HttpServletRequest req){
        CkCommand cmd = CkCommand.valueOf(req.getParameter("command"));
        CkContentType type = CkContentType.valueOf(req.getParameter("type"));
        if(cmd == CkCommand.Init){
            return new InitCommand(cmd, type);
        } else if(cmd == CkCommand.GetFolders){
            return new GetFoldersCommand(cmd, type);
        } else if(cmd == CkCommand.GetFiles){
            return new GetFilesCommand(cmd, type);
        }

        return null;
    }

}
